package cn.gok.oop;

import java.util.Scanner;

class Animal{
    public void call(){
        System.out.println("动物发出叫声");
    }
}
interface Library{
    void borrowBook();
    void returnBook();
}
public class 匿名内部类 {
    public static void main(String[] args) {
        System.out.println("请输入叫声");
        Scanner sc = new Scanner(System.in);
        String str = sc.nextLine();
        Animal animal = new Animal(){
            @Override
            public void call() {
                System.out.println(str);
            }
        };
        //调用匿名内部类的方法
        animal.call();
        Library library = new Library() {
            @Override
            public void borrowBook() {
                System.out.println("借书");
            }

            @Override
            public void returnBook() {
                System.out.println("还书");
            }
        };
        library.borrowBook();
        library.returnBook();
    }
}
